<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>2249：Pku3896 Multiprocessor Scheduling</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">Pku3896 Multiprocessor Scheduling</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">Pku3896 Multiprocessor Scheduling</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                Pku3896 Multiprocessor Scheduling                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：128MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><div class="plm"></div>
<div lang="en-US" class="ptx"><span style="font-size: medium">There are two applications running on a multiprocessor machine. Each application i (i=1,2) consists of N procedures which are numbered from 1 to N and must be executed sequentially (in the order 1,...,N). A procedure will be identified by a pair (i,j), where i=1,2 identifies the application and 1&le;j&le;N represents the index of the procedure in the sequence of procedures of the application i. A procedure (i,j) can only be executed on the processor P(i,j) of the machine and its execution lasts for D(i,j) seconds. We want to schedule the execution of the procedures of the two applications over the processors of the machine in such a way that the time moment when the last procedure finishes its execution (from any of the two applications) is minimum; this time moment is called makespan. We consider that the two applications are available for scheduling starting from the time moment 0. The schedule needs to obey the following rules: <br />
</span>
<p style="padding-left: 30px"><span style="font-size: medium"><br />
once the execution of a procedure (i,j) starts on the processor P(i,j), we cannot interrupt it until the execution of the procedure ends <br />
we cannot execute multiple procedures on the same processor at the same time, but we can execute multiple procedures in parallel on different processors <br />
the execution of the procedure (i,j) (2&le;j&le;N) starts either at the exact time moment tm when the procedure (i,j-1) finishes its execution or at any time moment after tm <br />
if a procedure begins its execution at time moment tm, then it will finish its execution at the time moment tm+D(i,j) <br />
</span></p>
<span style="font-size: medium"><br />
</span></div>
<div style="widows: 2; text-transform: none; text-indent: 0px; font: 14px/23px 幼圆; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-size: medium">有两组任务，每组都有N个任务，现在将这些任务放到一些处理器中处理，条件如下：&nbsp;</span></div>
<div style="widows: 2; text-transform: none; text-indent: 0px; font: 14px/23px 幼圆; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-size: medium">1.任意一组任务必须按顺序完成，也就是必须先做完前i-1个才能做第i个。&nbsp;</span></div>
<div style="widows: 2; text-transform: none; text-indent: 0px; font: 14px/23px 幼圆; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-size: medium">2.某个任务只能在指定的处理器（编号不超过10）上做。&nbsp;</span></div>
<div style="widows: 2; text-transform: none; text-indent: 0px; font: 14px/23px 幼圆; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-size: medium">3.一个处理器同一时间只能处理一个任务，并且不允许中断。&nbsp;</span></div>
<div style="widows: 2; text-transform: none; text-indent: 0px; font: 14px/23px 幼圆; white-space: normal; orphans: 2; letter-spacing: normal; color: rgb(0,0,0); word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px"><span style="font-size: medium">求完成两组任务的最短时间。</span></div></p><hr/><h3>输入格式</h3><p><p>Write a program that, given the information regarding the procedures of the two applications, computes the minimum makespan.</p>
<div lang="en-US" class="ptx">The first line of the input file contains the number T of test cases which are described next. The first line of a test case contains the number N (1&le;N&le;300) of procedures composing each of the two applications. Then, N lines follow, describing the first application. The j<sup>th</sup> of these N lines contains two integers, separated by a blank: P(1,j) and D(1,j). After this, other N lines follow, describing the second application. The j<sup>th</sup> of these N lines contains two integers, separated by a blank: P(2,j) and D(2,j). We have 1&le;P(i,j)&le;10 and 1&le;D(i,j)&le;15000 (i=1,2; 1&le;j&le;N). Notice that we may have P(i,j)=P(k,l) &ndash; this implies that the procedures (i,j) and (k,l) cannot be executed during overlapping time intervals (notice also that if i=k this would not matter, as the procedures of the same application must be executed sequentially).</div></p><hr/><h3>输出格式</h3><p><div lang="en-US" class="ptx">The output file must contain exactly T lines with a single number each &ndash; the minimum makespan for the corresponding test from the input file. These answers must be printed in the order in which the test cases are given in the input file (i.e. the i<sup>th</sup> line of the output file contains the answer to the i<sup>th</sup> test case from the input file).</div></p><hr/><h3>样例输入</h3><pre>2 
1 
2 6 
1 10 
3 
2 31 
2 18 
4 15 
2 26 
3 40 
5 16
</pre><hr/><h3>样例输出</h3><pre>10 
90
</pre><hr/><h3>提示</h3><p>没有写明提示</p><hr/><h3>题目来源</h3><p>Seerc2009</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=2249" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=2249" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>